import 'package:flutter/material.dart';

typedef VisibilityExtBuilder = Widget Function();

class VisibilityExt extends StatelessWidget {
  const VisibilityExt({
    @required this.visible,
    @required this.builder,
    this.replacement = const SizedBox.shrink(),
  })  : assert(builder != null),
        assert(replacement != null),
        assert(visible != null);

  final VisibilityExtBuilder builder;
  final Widget replacement;
  final bool visible;

  @override
  Widget build(BuildContext context) {
    return visible ? builder() : replacement;
  }
}
